package com.banciyuan.bcywebview.biz.apprecommend.decoration;

import android.content.Context;
import android.graphics.Rect;
import android.support.v7.widget.RecyclerView;
import android.view.View;

import com.banciyuan.bcywebview.utils.common.UIUtils;

/**
 * Created by squall on 2017/3/31.
 */

public class AcgDecoration extends RecyclerView.ItemDecoration {

    private Context mContext;

    public AcgDecoration(Context mContext) {
        this.mContext = mContext;
    }

    @Override
    public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
        int type = parent.getAdapter().getItemViewType(parent.getChildAdapterPosition(view));
        int index = parent.getChildAdapterPosition(view) % 3;
        if (type == 1) {
            if (index == 0) {
                outRect.right = 0;
            } else {
                outRect.right = UIUtils.dip2px(2, mContext);
            }
            outRect.top = UIUtils.dip2px(2, mContext);
        }
    }
}
